package com.fr.report.js;

import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.util.Utils;
import com.fr.web.Repository;

public abstract class AbstractHyperlink extends AbstractJavaScript
  implements Hyperlink
{
  private String targetFrame = "_blank";
  public static final String SELF_FRAME = "_self";
  public static final String BLANK_FRAME = "_blank";
  private static final String STATUS = "status";
  private static final String TOOLBAR = "toolbar";
  private static final String LOCATION = "location";
  private static final String MENUBAR = "menubar";
  private static final String RESIZABLE = "resizable";
  private static final String DIRECTORIES = "directories";
  private static final String SCROLLBARS = "scrollbars";
  private static final String WIDTH = "width";
  private static final String HEIGHT = "height";
  private boolean showStatus = true;
  private boolean showToolbar = true;
  private boolean showLocation = true;
  private boolean showMenubar = true;
  private boolean showDirectories = true;
  private boolean showScrollbars = true;
  private boolean resizable = true;
  private int width = 0;
  private int height = 0;

  public String features4NewWindow()
  {
    StringBuffer localStringBuffer = new StringBuffer();
    if (this.width > 0)
      localStringBuffer.append("width").append("=").append(this.width).append(",");
    if (this.height > 0)
      localStringBuffer.append("height").append("=").append(this.height).append(",");
    if ((!(this.showStatus)) || (!(this.showToolbar)) || (!(this.showLocation)) || (!(this.showMenubar)) || (!(this.resizable)) || (!(this.showDirectories)) || (!(this.showScrollbars)))
      localStringBuffer.append("status").append("=").append((this.showStatus) ? 1 : 0).append(",").append("toolbar").append("=").append((this.showToolbar) ? 1 : 0).append(",").append("location").append("=").append((this.showLocation) ? 1 : 0).append(",").append("menubar").append("=").append((this.showMenubar) ? 1 : 0).append(",").append("resizable").append("=").append((this.resizable) ? 1 : 0).append(",").append("directories").append("=").append((this.showDirectories) ? 1 : 0).append(",").append("scrollbars").append("=").append((this.showScrollbars) ? 1 : 0);
    return localStringBuffer.toString();
  }

  public String getTargetFrame()
  {
    return this.targetFrame;
  }

  public void setTargetFrame(String paramString)
  {
    this.targetFrame = paramString;
  }

  public boolean isShowStatus()
  {
    return this.showStatus;
  }

  public void setShowStatus(boolean paramBoolean)
  {
    this.showStatus = paramBoolean;
  }

  public boolean isShowToolbar()
  {
    return this.showToolbar;
  }

  public void setShowToolbar(boolean paramBoolean)
  {
    this.showToolbar = paramBoolean;
  }

  public boolean isShowLocation()
  {
    return this.showLocation;
  }

  public void setShowLocation(boolean paramBoolean)
  {
    this.showLocation = paramBoolean;
  }

  public boolean isShowMenubar()
  {
    return this.showMenubar;
  }

  public void setShowMenubar(boolean paramBoolean)
  {
    this.showMenubar = paramBoolean;
  }

  public boolean isResizable()
  {
    return this.resizable;
  }

  public void setResizable(boolean paramBoolean)
  {
    this.resizable = paramBoolean;
  }

  public boolean isShowDirectories()
  {
    return this.showDirectories;
  }

  public void setShowDirectories(boolean paramBoolean)
  {
    this.showDirectories = paramBoolean;
  }

  public boolean isShowScrollbars()
  {
    return this.showScrollbars;
  }

  public void setShowScrollbars(boolean paramBoolean)
  {
    this.showScrollbars = paramBoolean;
  }

  public int getWidth()
  {
    return this.width;
  }

  public void setWidth(int paramInt)
  {
    this.width = paramInt;
  }

  public int getHeight()
  {
    return this.height;
  }

  public void setHeight(int paramInt)
  {
    this.height = paramInt;
  }

  public String createJS(Repository paramRepository)
  {
    return createURL(paramRepository);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    String[] arrayOfString;
    int i;
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1;
      if (paramXMLableReader.getTagName().equals("TargetFrame"))
      {
        str1 = null;
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getElementValue()))
          setTargetFrame(str1);
      }
      else if (paramXMLableReader.getTagName().equals("Features"))
      {
        str1 = null;
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("status")))
          setShowStatus(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("toolbar")))
          setShowToolbar(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("location")))
          setShowLocation(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("menubar")))
          setShowMenubar(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("resizable")))
          setResizable(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("directories")))
          setShowDirectories(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("scrollbars")))
          setShowScrollbars(Boolean.valueOf(str1).booleanValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("width")))
          setWidth(Utils.string2Number(str1).intValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getAttr("height")))
          setHeight(Utils.string2Number(str1).intValue());
        if (StringUtils.isNotBlank(str1 = paramXMLableReader.getElementValue()))
        {
          String str2 = str1;
          arrayOfString = str2.split(",");
          for (i = 0; i < arrayOfString.length; ++i)
          {
            String str3 = arrayOfString[i];
            String str4 = str3.split("=")[0];
            String str5 = str3.split("=")[1];
            if ("width".equalsIgnoreCase(str4))
              setWidth(Utils.string2Number(str5).intValue());
            else if ("height".equalsIgnoreCase(str4))
              setHeight(Utils.string2Number(str5).intValue());
            else if ("status".equalsIgnoreCase(str4))
              setShowStatus(string2Boolean4XmlCompatation(str5));
            else if ("toolbar".equalsIgnoreCase(str4))
              setShowToolbar(string2Boolean4XmlCompatation(str5));
            else if ("location".equalsIgnoreCase(str4))
              setShowLocation(string2Boolean4XmlCompatation(str5));
            else if ("menubar".equalsIgnoreCase(str4))
              setShowMenubar(string2Boolean4XmlCompatation(str5));
            else if ("resizable".equalsIgnoreCase(str4))
              setResizable(string2Boolean4XmlCompatation(str5));
            else if ("directories".equalsIgnoreCase(str4))
              setShowDirectories(string2Boolean4XmlCompatation(str5));
            else if ("scrollbars".equalsIgnoreCase(str4))
              setShowScrollbars(string2Boolean4XmlCompatation(str5));
          }
        }
      }
    }
  }

  private static boolean string2Boolean4XmlCompatation(String paramString)
  {
    if ("1".equals(paramString))
      return true;
    if ("0".equals(paramString))
      return false;
    return Boolean.valueOf(paramString).booleanValue();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (StringUtils.isNotBlank(getTargetFrame()))
      paramXMLPrintWriter.startTAG("TargetFrame").textNode(getTargetFrame()).end();
    paramXMLPrintWriter.startTAG("Features").attr("status", this.showStatus).attr("toolbar", this.showToolbar).attr("location", this.showLocation).attr("menubar", this.showMenubar).attr("resizable", this.resizable).attr("directories", this.showDirectories).attr("scrollbars", this.showScrollbars);
    if (this.width > 0)
      paramXMLPrintWriter.attr("width", this.width);
    if (this.height > 0)
      paramXMLPrintWriter.attr("height", this.height);
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (paramObject == this)
      return true;
    if (!(paramObject instanceof AbstractHyperlink))
      return false;
    return ((super.equals(paramObject)) && (this.showDirectories == ((AbstractHyperlink)paramObject).showDirectories) && (this.showScrollbars == ((AbstractHyperlink)paramObject).showScrollbars) && (this.showLocation == ((AbstractHyperlink)paramObject).showLocation) && (this.showMenubar == ((AbstractHyperlink)paramObject).showMenubar) && (this.showStatus == ((AbstractHyperlink)paramObject).showStatus) && (this.showToolbar == ((AbstractHyperlink)paramObject).showToolbar) && (this.resizable == ((AbstractHyperlink)paramObject).resizable) && (this.height == ((AbstractHyperlink)paramObject).height) && (this.width == ((AbstractHyperlink)paramObject).width) && (ComparatorUtils.equals(this.targetFrame, ((AbstractHyperlink)paramObject).targetFrame)));
  }
}